package edu.zqxy.eastmoney.controller;

import edu.zqxy.eastmoney.dto.PageDto;
import edu.zqxy.eastmoney.dto.ResponseDto;
import edu.zqxy.eastmoney.pojo.Stock;
import edu.zqxy.eastmoney.service.IStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/stock")
public class StockController {
    @Autowired
    IStockService stockService;

    @RequestMapping("getStockByCode")

        public ResponseDto getStockById(String code){
            // int i=100/0;
            Stock stock=stockService.findById(code);
            ResponseDto responseDto=new ResponseDto(0,"处理成功",stock);
            return responseDto;


}
    @RequestMapping("selectAllPage")
    public ResponseDto selectAllPage(int pageNo,int pageSize){
        // int i=100/0;
        PageDto<Stock>allPage =stockService.findAllPage(pageNo,pageSize);
        ResponseDto responseDto=new ResponseDto(0,"处理成功",allPage);
        return responseDto;}
//@ExceptionHandler
////捕获上面的异常
//    public ResponseDto exceptionHandle(Exception ex){
//
//    ResponseDto responseDto=new ResponseDto(-1,"处理失败"+ex.getMessage(),null);
//            return responseDto;
//}



}
